package cn.edu.sjtu.se.dslab.service.impl;

import java.util.Date;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.edu.sjtu.se.dslab.action.bean.PageBean;
import cn.edu.sjtu.se.dslab.component.design.DesignPatternInstance;
import cn.edu.sjtu.se.dslab.dao.IDesignPatternInstanceDao;
import cn.edu.sjtu.se.dslab.exception.DBException;
import cn.edu.sjtu.se.dslab.service.IDesignPatternInstanceService;

/**
 * 
 * @author longshaohang
 *
 */

@Service("designPatternInstanceService")
@Transactional
public class DesignPatternInstanceServiceImpl implements IDesignPatternInstanceService {

	@Resource(name="designPatternInstanceDao")
	IDesignPatternInstanceDao designPatternInstanceDao;
	
	@Override
	public boolean addDesignPatternInstance(DesignPatternInstance dpi) {
		dpi.setCreateTime(new Date());
		designPatternInstanceDao.save(dpi);
		return true;
	}

	@Override
	public DesignPatternInstance updateDesignPatternInstance(
			DesignPatternInstance dpi) {
		designPatternInstanceDao.update(dpi);
		return null;
	}

	@Override
	public DesignPatternInstance getDesignPatternInstanceById(long id) {
		return designPatternInstanceDao.queryById(id);
	}

	@Override
	public PageBean getPageBean(int pageNum) throws DBException {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<DesignPatternInstance> getDesignPatternInstanceList() {
		return designPatternInstanceDao.queryByList();
	}

}
